//
//  ZGSearchController.m
//  NewBee
//
//  Created by leergou on 16/8/21.
//  Copyright © 2016年 WhiteHouse. All rights reserved.
//

#import "ZGSearchController.h"

@interface ZGSearchController ()<UISearchBarDelegate>

@end

@implementation ZGSearchController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = RGBCOLOR(239, 239, 239);
    
    [self setupNav];
}

#pragma mark - 按钮点击 -
- (void)backButtonClick:(UIButton *)sender{
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark - UISearchBarDelegate -
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
    
    NSLog(@"%@",searchText);
    
}

#pragma mark - 设置导航 -
- (void)setupNav{
    
    [self.navigationController.navigationBar setBarTintColor:RGBCOLOR(249, 250, 253)];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"v2_goback"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(backButtonClick:)];
    
    // 添加 搜索框
    CGFloat searchBarWidth = 150;
    CGFloat searchBarHeight = NavigationH * 0.8;
    CGFloat searchBarX = (SCREEN_WIDTH - searchBarWidth) * 0.5;
    CGFloat searchBarY = (NavigationH - searchBarHeight) * 0.5;
    UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(searchBarX, searchBarY, searchBarWidth, searchBarHeight)];
    searchBar.placeholder = @"请输入商品名称";
    searchBar.delegate = self;
    
    self.navigationItem.titleView = searchBar;
}




@end
